<?php
namespace Home\Controller;
use Think\Controller;
use Think\Upload;

class CommonController extends Controller {

	public function __construct(){
		parent::__construct();
		
		if(empty($_SESSION['user']))
		{
			 $this->error('对不起,您还没有登录!请先登录!', U('Login/login'), 1);
			
		}
	}


	public function file_uplaod($conf){

		$upload = new \Think\Upload($conf);// 实例化上传类
	    $upload->maxSize   =     31457280 ;// 设置附件上传大小
	    $upload->exts      =     array('apk', 'pdf');// 设置附件上传类型
	    $upload->rootPath  =     ROOT_PATH; // 设置附件上传根目录
	    $upload->savePath  =     DOC_PATH.'/';// 设置附件上传（子）目录
	    $upload->subName   =     array('date','Ymd');
	    // 上传文件 
	    $info   =   $upload->upload();
	    if(!$info) {// 上传错误提示错误信息
	        $this->error($upload->getError());
	    }else{// 上传成功
	        return $info;
	    }
	}


}